package com.learn;

import javafx.util.Pair;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;

public class TestTool {

    public static <T,R>void testAndPrintTime(Runnable runnable,int times,String desc){

        long start1 = System.currentTimeMillis();

        while(times -- > 0) {
            runnable.run();
        }

        long end1 = System.currentTimeMillis();
        System.out.println(desc + "耗时"+(end1 - start1));
    }

    public static void main(String[] args) {

        List<Pair<Integer,Integer>> list = new ArrayList<>();

        int num = 20000;
        int circle = 100;
        for (int i = 0; i < num; i++) {
            list.add(new Pair<>(i,i));
        }


        long start = System.currentTimeMillis();

        while(circle-- > 0) {
            for (int i = 0; i < list.size(); i++) {
                Pair<Integer,Integer> item = list.get(i);
                if (item.getKey() > 5) {
                    if (item.getKey() > 10) {
                        if (item.getValue() > 15) {
                            if (item.getValue() > 20) {

                            }
                        }
                    }
                }
            }
        }
        long end = System.currentTimeMillis();

        System.out.println("100次花费:" + (end - start));

    }

}
